package com.xingchi.framework.common.utils;

import com.xingchi.framework.common.exception.ExceptionWrap;
import com.xingchi.framework.common.model.CommonCode;

/**
 * 异常断言工具类
 *
 * @author xingchi
 * @date 2022/8/22 22:22
 * @modified xingchi
 */
public class Assert {

    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            ExceptionWrap.cast(CommonCode.PARAM_CHECK_FAIL, message);
        }
    }

    public static void isFalse(boolean expression, String message) {
        if (expression) {
            ExceptionWrap.cast(CommonCode.PARAM_CHECK_FAIL, message);
        }
    }

    public static void isNull(Object object, String message) {
        if (object != null) {
            ExceptionWrap.cast(CommonCode.PARAM_CHECK_FAIL, message);
        }
    }

    public static void nonNull(Object object, String message) {
        if (object == null) {
            ExceptionWrap.cast(CommonCode.PARAM_CHECK_FAIL, message);
        }
    }

}
